#include <iostream>
#include <string>

using namespace std;

// 复数类
class Complex
{
private:
	double real;
	double imag;

public:
	Complex()
		: real(0), imag(0)
	{
	}

	Complex(double real, double imag) : real(real), imag(imag)
	{
	}
	~Complex()
	{
		}

public:
	//++运算符重载 成员函数运算个重载
	Complex operator+(Complex R)
	{

		Complex x;
		x.imag = this->imag + R.imag;
		x.real = this->real + R.real;
		return x;
	}
	// 显示
	void Show()
	{
		cout << "实部" << real << "虚部" << imag << endl;
	}
	friend Complex operator*(Complex L, Complex R);
};
// 全局函数函数重载   称为Complex的友元函数 使用类中的私有成员
// 运算符*的重载函数
Complex operator*(Complex L, Complex R)
{

	Complex x;
	x.real = L.real * R.imag;
	x.imag = L.imag * R.imag;
	return x;
}

int main(int argc, char const *argv[])
{
	// 示例对象 并初始化
	Complex F1(1.2, 3.14);

	Complex F2(3, 4);
	Complex F3;
	// 加法
	F3 = F1 + F2;
	F3.Show();


	// 乘法
	F3 = F1 * F2;
	F3.Show();

	return 0;
}
